﻿<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="html" indent="yes" encoding="utf-8" />
  <xsl:template match="/">
    <xsl:text disable-output-escaping="yes"><![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">]]></xsl:text>
    <html>
      <head>
        <xsl:text disable-output-escaping="yes"><![CDATA[<meta charset="utf-8">]]></xsl:text>
        <xsl:text disable-output-escaping="yes"><![CDATA[<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">]]></xsl:text>

        <title>Type Difference</title>

        <xsl:text disable-output-escaping="yes"><![CDATA[<meta name="description" content="">]]></xsl:text>
        <xsl:text disable-output-escaping="yes"><![CDATA[<meta name="viewport" content="width=device-width">]]></xsl:text>

        <style type="text/css">
          <xsl:comment>Styles here </xsl:comment>
        </style>

      </head>
      <body>
        <xsl:apply-templates select="TypeDifference" />

        <xsl:text disable-output-escaping="yes"><![CDATA[<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>]]></xsl:text>

        <xsl:comment>Local Javascript here </xsl:comment>
        <xsl:text disable-output-escaping="yes"><![CDATA[<script>
		$(document).ready(function() {

			$('tr:even').addClass('even');
			
			$('a.toggle').click(function() {

				var table = $(this).parent().parent().next();

				var newPrompt = '';

				if (table.is(':hidden')) {
					newPrompt = 'Hide';
				} else {
					newPrompt = 'Show';
				}

				table.slideToggle();
				$(this).text(newPrompt);
				
				return false;
			});
		});

	</script>]]></xsl:text>

      </body>
    </html>

  </xsl:template>

  <xsl:template match="TypeDifference">
    <div id="header">
        <h1>
          <xsl:value-of select="@Name" />
        </h1>
        <p>
          <xsl:value-of select="@NamespaceName" />
        </p>
        <!-- <p><xsl:apply-templates select="SourceDefinition" /></p>-->

      <xsl:call-template name="navigation" />
    </div>

    <!-- Top level changes -->

    <xsl:apply-templates select="TypeTaxonomy" />
    <xsl:apply-templates select="InheritanceChanged" />

    <!-- Removed -->
    <xsl:apply-templates select="ConstantsRemoved" />
    <xsl:apply-templates select="FieldsRemoved" />
    <xsl:apply-templates select="ConstructorsRemoved" />
    <xsl:apply-templates select="FinalizersRemoved" />
    <xsl:apply-templates select="EventsRemoved" />
    <xsl:apply-templates select="PropertiesRemoved" />
    <xsl:apply-templates select="IndexersRemoved" />
    <xsl:apply-templates select="MethodsRemoved" />
    <xsl:apply-templates select="ValuesRemoved" />

    <!-- Obsolete -->
    <xsl:apply-templates select="ConstantsObsolete" />
    <xsl:apply-templates select="FieldsObsolete" />
    <xsl:apply-templates select="ConstructorsObsolete" />
    <xsl:apply-templates select="EventsObsolete" />
    <xsl:apply-templates select="PropertiesObsolete" />
    <xsl:apply-templates select="IndexersObsolete" />
    <xsl:apply-templates select="MethodsObsolete" />

    <!-- Changed -->
    <xsl:apply-templates select="ConstantsChanged" />
    <xsl:apply-templates select="FieldsChanged" />
    <xsl:apply-templates select="ConstructorsChanged" />
    <xsl:apply-templates select="EventsChanged" />
    <xsl:apply-templates select="PropertiesChanged" />
    <xsl:apply-templates select="IndexersChanged" />
    <xsl:apply-templates select="MethodsChanged" />

    <!-- Added -->
    <xsl:apply-templates select="ConstantsAdded" />
    <xsl:apply-templates select="FieldsAdded" />
    <xsl:apply-templates select="ConstructorsAdded" />
    <xsl:apply-templates select="FinalizersAdded" />
    <xsl:apply-templates select="EventsAdded" />
    <xsl:apply-templates select="PropertiesAdded" />
    <xsl:apply-templates select="IndexersAdded" />
    <xsl:apply-templates select="MethodsAdded" />
    <xsl:apply-templates select="ValuesAdded" />

    <!-- TODO:Finalizers -->

    <!-- TODO:Delegates -->

    <div id="footer">
      <xsl:call-template name="navigation" />
      <p>
        Generated by
        <a>
          <xsl:attribute name="href">
            <xsl:value-of select="@ProductLink" />
          </xsl:attribute>
          <xsl:value-of select="@ProductName" /> version <xsl:value-of select="@ProductVersion" />
        </a>
      </p>
    </div>

  </xsl:template>


  <!-- Top level changes -->

  <xsl:template match="TypeTaxonomy">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'General Changes'" />
      <xsl:with-param name="caption" select="'General Changes'" />
      <xsl:with-param name="column1" select="'Change'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="InheritanceChanged">

    <xsl:call-template name="write_3column_article">
      <xsl:with-param name="title" select="'Inheritance Changes'" />
      <xsl:with-param name="caption" select="'Changes to inheritance hierarchy'" />
      <xsl:with-param name="column1" select="'Was'" />
      <xsl:with-param name="column2" select="'Is'" />
      <xsl:with-param name="column3" select="'Description'" />
    </xsl:call-template>

  </xsl:template>

  <!-- See below -->

  <xsl:template match="TypeInheritanceChange">

    <xsl:if test="not(@To = '')">
      <tr>
        <td>
          Base type changed from <code>
            <xsl:value-of select="@From" />
          </code> to <code>
            <xsl:value-of select="@To" />
          </code>
        </td>
      </tr>
    </xsl:if>

    <xsl:if test="@To = ''">
      <tr>
        <td>
          No longer derived from <code>
            <xsl:value-of select="@From" />
          </code>
        </td>
      </tr>
    </xsl:if>

  </xsl:template>


  <!-- Removed -->
  <xsl:template match="ConstantsRemoved">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Removed Constants'" />
      <xsl:with-param name="caption" select="'Removed Constants'" />
      <xsl:with-param name="column1" select="'Constant'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="FieldsRemoved">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Removed Fields'" />
      <xsl:with-param name="caption" select="'Removed Fields'" />
      <xsl:with-param name="column1" select="'Field'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="ConstructorsRemoved">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Removed Constructors'" />
      <xsl:with-param name="caption" select="'Removed Constructors'" />
      <xsl:with-param name="column1" select="'Signature'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="FinalizersRemoved">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Finalizer Removed'" />
      <xsl:with-param name="caption" select="'Removed Finalizer'" />
      <xsl:with-param name="column1" select="'Signature'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="EventsRemoved">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Removed Events'" />
      <xsl:with-param name="caption" select="'Removed Events'" />
      <xsl:with-param name="column1" select="'Event'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="PropertiesRemoved">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Removed Properties'" />
      <xsl:with-param name="caption" select="'Removed Properties'" />
      <xsl:with-param name="column1" select="'Property'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="IndexersRemoved">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Removed Indexers'" />
      <xsl:with-param name="caption" select="'Removed Indexers'" />
      <xsl:with-param name="column1" select="'Signature'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="MethodsRemoved">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Removed Methods'" />
      <xsl:with-param name="caption" select="'Removed Methods'" />
      <xsl:with-param name="column1" select="'Signature'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="ValuesRemoved">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Removed Enum Values'" />
      <xsl:with-param name="caption" select="'Removed Enum Values'" />
      <xsl:with-param name="column1" select="'Value'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>


  <!-- Obsolete -->
  <xsl:template match="ConstantsObsolete">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Obsolete Constants'" />
      <xsl:with-param name="caption" select="'Obsolete Constants'" />
      <xsl:with-param name="column1" select="'Constant'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="FieldsObsolete">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Obsolete Fields'" />
      <xsl:with-param name="caption" select="'Obsolete Fields'" />
      <xsl:with-param name="column1" select="'Field'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="ConstructorsObsolete">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Obsolete Constructors'" />
      <xsl:with-param name="caption" select="'Obsolete Constructors'" />
      <xsl:with-param name="column1" select="'Signature'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="EventsObsolete">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Obsolete Events'" />
      <xsl:with-param name="caption" select="'Obsolete Events'" />
      <xsl:with-param name="column1" select="'Event'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="PropertiesObsolete">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Obsolete Properties'" />
      <xsl:with-param name="caption" select="'Obsolete Properties'" />
      <xsl:with-param name="column1" select="'Property'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="IndexersObsolete">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Obsolete Indexers'" />
      <xsl:with-param name="caption" select="'Obsolete Indexers'" />
      <xsl:with-param name="column1" select="'Signature'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="MethodsObsolete">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Obsolete Methods'" />
      <xsl:with-param name="caption" select="'Obsolete Methods'" />
      <xsl:with-param name="column1" select="'Signature'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>


  <!-- Changed -->
  <xsl:template match="ConstantsChanged">

    <xsl:call-template name="write_3column_article">
      <xsl:with-param name="title" select="'Changed Constants'" />
      <xsl:with-param name="caption" select="'Changed Constants'" />
      <xsl:with-param name="column1" select="'Was'" />
      <xsl:with-param name="column2" select="'Is Now'" />
      <xsl:with-param name="column3" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="FieldsChanged">

    <xsl:call-template name="write_3column_article">
      <xsl:with-param name="title" select="'Changed Fields'" />
      <xsl:with-param name="caption" select="'Changed Fields'" />
      <xsl:with-param name="column1" select="'Was'" />
      <xsl:with-param name="column2" select="'Is Now'" />
      <xsl:with-param name="column3" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="ConstructorsChanged">

    <xsl:call-template name="write_3column_article">
      <xsl:with-param name="title" select="'Changed Constructors'" />
      <xsl:with-param name="caption" select="'Changed Constructors'" />
      <xsl:with-param name="column1" select="'Was'" />
      <xsl:with-param name="column2" select="'Is Now'" />
      <xsl:with-param name="column3" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="EventsChanged">

    <xsl:call-template name="write_3column_article">
      <xsl:with-param name="title" select="'Changed Events'" />
      <xsl:with-param name="caption" select="'Changed Events'" />
      <xsl:with-param name="column1" select="'Was'" />
      <xsl:with-param name="column2" select="'Is Now'" />
      <xsl:with-param name="column3" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="PropertiesChanged">

    <xsl:call-template name="write_3column_article">
      <xsl:with-param name="title" select="'Changed Properties'" />
      <xsl:with-param name="caption" select="'Changed Properties'" />
      <xsl:with-param name="column1" select="'Was'" />
      <xsl:with-param name="column2" select="'Is Now'" />
      <xsl:with-param name="column3" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="IndexersChanged">

    <xsl:call-template name="write_3column_article">
      <xsl:with-param name="title" select="'Changed Indexers'" />
      <xsl:with-param name="caption" select="'Changed Indexers'" />
      <xsl:with-param name="column1" select="'Was'" />
      <xsl:with-param name="column2" select="'Is Now'" />
      <xsl:with-param name="column3" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="MethodsChanged">

    <xsl:call-template name="write_3column_article">
      <xsl:with-param name="title" select="'Changed Methods'" />
      <xsl:with-param name="caption" select="'Changed Methods'" />
      <xsl:with-param name="column1" select="'Was'" />
      <xsl:with-param name="column2" select="'Is Now'" />
      <xsl:with-param name="column3" select="'Message'" />
    </xsl:call-template>

  </xsl:template>


  <!-- Added -->
  <xsl:template match="ConstantsAdded">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Added Constants'" />
      <xsl:with-param name="caption" select="'New Constants'" />
      <xsl:with-param name="column1" select="'Constant'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="FieldsAdded">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Added Fields'" />
      <xsl:with-param name="caption" select="'New Fields'" />
      <xsl:with-param name="column1" select="'Field'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="ConstructorsAdded">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Added Constructors'" />
      <xsl:with-param name="caption" select="'New Constructors'" />
      <xsl:with-param name="column1" select="'Signature'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="FinalizersAdded">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Added Finalizer'" />
      <xsl:with-param name="caption" select="'New Finalizer'" />
      <xsl:with-param name="column1" select="'Signature'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="EventsAdded">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Added Events'" />
      <xsl:with-param name="caption" select="'New Events'" />
      <xsl:with-param name="column1" select="'Event'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="PropertiesAdded">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Added Properties'" />
      <xsl:with-param name="caption" select="'New Properties'" />
      <xsl:with-param name="column1" select="'Property'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="IndexersAdded">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Added Indexers'" />
      <xsl:with-param name="caption" select="'New Indexers'" />
      <xsl:with-param name="column1" select="'Signature'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="MethodsAdded">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Added Methods'" />
      <xsl:with-param name="caption" select="'New Methods'" />
      <xsl:with-param name="column1" select="'Signature'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="ValuesAdded">

    <xsl:call-template name="write_2column_article">
      <xsl:with-param name="title" select="'Added Enum Values'" />
      <xsl:with-param name="caption" select="'New Enum values'" />
      <xsl:with-param name="column1" select="'Value'" />
      <xsl:with-param name="column2" select="'Message'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template name="write_2column_article" >
    <xsl:param name="title" />
    <xsl:param name="caption" />
    <xsl:param name="column1" />
    <xsl:param name="column2" />

    <div>
        <h2>
          <xsl:value-of select="$title" />
        </h2>
        <p>
          <a href="#" class="toggle">Hide</a>
        </p>
      <table>
        <xsl:attribute name="summary">
          <xsl:value-of select="$caption" />
        </xsl:attribute>
        <thead>
          <tr>
            <th>
              <xsl:value-of select="$column1" />
            </th>
            <th>
              <xsl:value-of select="$column2" />
            </th>
          </tr>
        </thead>
        <caption>
          <xsl:value-of select="$caption" />
        </caption>
        <tbody>
          <xsl:apply-templates />
        </tbody>
      </table>
    </div>
  </xsl:template>

  <xsl:template name="write_3column_article" >
    <xsl:param name="title" />
    <xsl:param name="caption" />
    <xsl:param name="column1" />
    <xsl:param name="column2" />
    <xsl:param name="column3" />

    <div>
        <h2>
          <xsl:value-of select="$title" />
        </h2>
        <p>
          <a href="#" class="toggle">Hide</a>
        </p>
      <table>
        <xsl:attribute name="summary">
          <xsl:value-of select="$caption" />
        </xsl:attribute>
        <thead>
          <tr>
            <th>
              <xsl:value-of select="$column1" />
            </th>
            <th>
              <xsl:value-of select="$column2" />
            </th>
            <th>
              <xsl:value-of select="$column3" />
            </th>
          </tr>
        </thead>
        <caption>
          <xsl:value-of select="$caption" />
        </caption>
        <tbody>
          <xsl:apply-templates />
        </tbody>
      </table>
    </div>
  </xsl:template>

  <xsl:template match="UnaryTypeChange">
    <xsl:comment>Unary Type Change</xsl:comment>
    <tr>
      <td>
        <xsl:apply-templates select="Code" />
      </td>
      <td>
        <xsl:value-of select="Message" />
      </td>
    </tr>
  </xsl:template>

  <xsl:template match="BinaryTypeChange">
    <xsl:comment>Binary Type Change</xsl:comment>
    <tr>
      <td>
        <xsl:apply-templates select="Was" />
      </td>
      <td>
        <xsl:apply-templates select="IsNow" />
      </td>
      <td>
        <xsl:apply-templates select="Message" />
      </td>
    </tr>
  </xsl:template>

  <xsl:template match="Code">
    <xsl:comment>Code</xsl:comment>
    <code>
      <xsl:apply-templates />
    </code>
  </xsl:template>

  <xsl:template match="Was">
    <xsl:comment>Was</xsl:comment>
    <code>
      <xsl:apply-templates />
    </code>
  </xsl:template>

  <xsl:template match="IsNow">
    <xsl:comment>IsNow</xsl:comment>
    <code>
      <xsl:apply-templates />
    </code>
  </xsl:template>

  <xsl:template match="SourceCode">
    <xsl:comment>Source Code</xsl:comment>
    <code>
      <xsl:apply-templates />
    </code>
  </xsl:template>

  <xsl:template match="punc">
    <xsl:comment>Punctuation</xsl:comment>
    <span class="punc">
      <xsl:value-of select="." />
    </span>
  </xsl:template>

  <xsl:template match="ident">
    <xsl:comment>Identifier</xsl:comment>
    <span class="ident">
      <xsl:value-of select="." />
    </span>
  </xsl:template>

  <xsl:template match="kw">
    <xsl:comment>Key Word</xsl:comment>
    <span class="kw">
      <xsl:value-of select="." />
    </span>
  </xsl:template>

  <xsl:template match="tn">
    <xsl:comment>TypeName</xsl:comment>
    <span class="tn">
      <xsl:value-of select="." />
    </span>
  </xsl:template>

  <xsl:template name="navigation">
    <div id="navigation">
      <ul>
        <li>
          <a>
            <xsl:attribute name="href">
              <xsl:value-of select="@SummaryName" />.html
            </xsl:attribute>Summary
          </a>
        </li>
        <li>
          <xsl:text disable-output-escaping="yes">&gt;</xsl:text>
        </li>
        <li>
          <a>
            <xsl:attribute name="href">
              <xsl:value-of select="@AssemblyName" />.html
            </xsl:attribute>
            <xsl:value-of select="@AssemblyName" />
          </a>
        </li>
      </ul>
    </div>
  </xsl:template>

</xsl:stylesheet>
